/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qsdm.es.persistence;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alberto
 */
@Entity
@Table(name = "sectorprofesional", catalog = "qsdm", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Sectorprofesional.findAll", query = "SELECT s FROM Sectorprofesional s"),
    @NamedQuery(name = "Sectorprofesional.findById", query = "SELECT s FROM Sectorprofesional s WHERE s.id = :id"),
    @NamedQuery(name = "Sectorprofesional.findByCodigo", query = "SELECT s FROM Sectorprofesional s WHERE s.codigo = :codigo"),
    @NamedQuery(name = "Sectorprofesional.findByNombre", query = "SELECT s FROM Sectorprofesional s WHERE s.nombre = :nombre")})
public class Sectorprofesional implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Column(name = "codigo", length = 45)
    private String codigo;
    @Column(name = "nombre", length = 512)
    private String nombre;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "sectorProfesional", fetch = FetchType.LAZY)
    private List<Profesion> profesionList;
    @OneToMany(mappedBy = "sectorProfesionalPadre", fetch = FetchType.LAZY)
    private List<Sectorprofesional> sectorprofesionalList;
    @JoinColumn(name = "sectorProfesionalPadre", referencedColumnName = "id")
    @ManyToOne(fetch = FetchType.LAZY)
    private Sectorprofesional sectorProfesionalPadre;

    public Sectorprofesional() {
    }

    public Sectorprofesional(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    @XmlTransient
    public List<Profesion> getProfesionList() {
        return profesionList;
    }

    public void setProfesionList(List<Profesion> profesionList) {
        this.profesionList = profesionList;
    }

    @XmlTransient
    public List<Sectorprofesional> getSectorprofesionalList() {
        return sectorprofesionalList;
    }

    public void setSectorprofesionalList(List<Sectorprofesional> sectorprofesionalList) {
        this.sectorprofesionalList = sectorprofesionalList;
    }

    public Sectorprofesional getSectorProfesionalPadre() {
        return sectorProfesionalPadre;
    }

    public void setSectorProfesionalPadre(Sectorprofesional sectorProfesionalPadre) {
        this.sectorProfesionalPadre = sectorProfesionalPadre;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sectorprofesional)) {
            return false;
        }
        Sectorprofesional other = (Sectorprofesional) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.qsdm.es.persistence.Sectorprofesional[ id=" + id + " ]";
    }
    
}
